﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using NTmdb;
using NTmdb.Common;
using NTmdb.Net;

namespace TestProject
{
    public class Program
    {
        public static void Main( String[] args )
        {
            Task.WaitAll( MainAsync( args ) );

            Console.ReadKey(); Console.ReadKey(); Console.ReadKey(); Console.ReadKey();
        }

        public static async Task MainAsync( string[] args )
        {
            var api = new ApiWrapper
                {
                    ApiClient = new ApiClientNet(),
                    ApiConfiguration = new ApiConfiguration
                        {
                            ApiKeyParameterName = "api_key",
                            ApiKey = "ba9a4d5a02b4438300a712d31316a3ff",
                            ApiUrl = "http://api.themoviedb.org/3",
                            ConfigurationMethodName = "configuration",
                            AuthenticationTokenMethodName = "authentication/token/new",
                            SessionMethodName = "authentication/session/new",
                            RequestTokenParameterName = "request_token",
                            GuestSessionMethodName = "authentication/guest_session/new",
                            JsonDateTimePattern = "yyyy-MM-dd HH:mm:ss 'UTC'",
                            JsonDatePattern = "yyyy-MM-dd",
                            MovieMethodName = "movie/{0}",
                            LanguageParameterName = "language",
                            AlternativeTitlesMethodName = "movie/{0}/alternative_titles",
                            CountryParameterName = "country",
                            CastMethodName = "movie/{0}/casts",
                            ImagesMethodName = "movie/{0}/images",
                            KeywordsMethodName = "movie/{0}/keywords",
                            ReleasesMethodName = "movie/{0}/releases",
                            TrailersMethodName = "movie/{0}/trailers",
                            TranslationsMethodName = "movie/{0}/translations",
                            SimilarMoviesMethodName = "movie/{0}/similar_movies",
                            ReviewsMethodName = "movie/{0}/reviews",
                            PageParameterName = "page",
                            ListsMethodName = "movie/{0}/lists",
                            ChangesMethodName = "movie/{0}/changes",
                            EndDateParameterName = "end_date",
                            StartDateParameterName = "start_date",
                            LatestMethodName = "movie/latest",
                            UpcomingMethodName = "movie/upcoming"
                        }
                };

            //var configRes = await api.GetConfigurationAsync();
            //var token = await api.GetAuthenticationTokenAsync();
            //var session = await api.GetSessionAsync( token.TmdbMoviePreview );
            //var guestSession = await api.GetGuestSessionAsync();
            //var movie = await api.GetMovieAsync( 550 );
            //var alternativeTitles = await api.GetAlternativeTitlesAsync( 550);
            //var staff = await api.GetCastAsync( 550 );
            //var imags = await api.GetImagesAsync( 550 );
            //var keywords = await api.GetKeywordsAsync( 550 );
            //var releases = await api.GetReleasesAsync( 550 );
            //var trailers = await api.GetTrailersAsync( 550 );
            //var translations = await api.GetTranslationsAsync( 550 );
            //var similarMovies = await api.GetSimilarMoviesAsync( 550 );
            //var similarMovies = await api.GetSimilarMoviesAsync(550);
            //var similarMovies1 = await api.GetSimilarMoviesAsync(550, 2, "DE");
            //var reviews = await api.GetReviewsAsync(49026);
            //var reviews1 = await api.GetReviewsAsync(49026,1,"EN");
            //var lists = await api.GetListsAsync(578);
            //var changes = await api.GetChangesAsync(68726, DateTime.Now, new DateTime(1999, 1, 1));
            //var latest = await api.GetLatestAsync();
            //var upcoming = await api.GetUpcomingAsync();

        }
    }
}





/*
 *     [Flags]
    public enum MovieMethods
    {
        AlternativeTitles = 1,
        Casts = 2,
        Iamges = 4,
        Keywords =8,
        Releases = 16,
        All = 17
    }
 * 

            Test( MovieMethods.AlternativeTitles );
            Test(MovieMethods.Casts);
            Test(MovieMethods.Iamges);
            Test(MovieMethods.Keywords);
            Test(MovieMethods.Releases);
            Test(MovieMethods.All);

            Test(MovieMethods.AlternativeTitles | MovieMethods.Casts);
 * 
 *         public static void Test( MovieMethods methodsToAppend )
        {
            Console.WriteLine( methodsToAppend );
            if((methodsToAppend & MovieMethods.Casts) == MovieMethods.Casts)
                Console.WriteLine( "CAST!!!!" );
        }
 * */

/*Parallel.For( 1, 10000, async i =>  
                {
                    var movie = await api.GetMovieAsync( i, "DE" );
                    if(movie.Error != null)
                        Console.WriteLine("Loading movie with ID: {0} failed, {1}", i, movie.Error.Message);
                    else
                        Console.WriteLine( "Movie with ID: {0} is: {1}", i, movie.TmdbReview.Title );
                } );

            Console.ReadLine();
            Console.ReadLine();*/